package com.asen.commons.core.base.enums;

import com.asen.commons.core.base.IntegerEnum;
import io.swagger.annotations.ApiModel;

/**
 * 字典数据类型
 *
 * @author Gary
 * @version 1.0
 * @date 2018-12-11
 */
@ApiModel("值类型")
public enum ValueTypeEnum implements IntegerEnum {

    /**
     * 枚举值
     */
    MENU(0, "菜单"),

    TEXT(1, "文本"),

    INTEGER(2, "整数"),

    DECIMAL(3, "小数"),

    BOOL(4, "布尔"),

    DATETIME(5, "日期时间"),

    DATE(6, "日期"),

    TIME(7, "时间"),

    ENTRY(8, "钉钉分录");

    private Integer key;

    private String val;

    ValueTypeEnum(Integer key, String val) {
        this.key = key;
        this.val = val;
    }

    @Override
    public Integer getValue() {
        return key;
    }

    @Override
    public String getDesc() {
        return val;
    }

    public static ValueTypeEnum getEnumByValue(Integer value) {
        ValueTypeEnum[] enums = ValueTypeEnum.values();
        for (ValueTypeEnum valueEnum : enums) {
            if (valueEnum.getValue().equals(value)) {
                return valueEnum;
            }
        }
        return null;
    }

}
